package com.bwie.controller;

import com.bwie.pojo.TbType;
import com.bwie.service.TbTypeService;
import com.bwie.utils.Result;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: zhaijiaqi
 * @Date: 2025/5/24 10:45
 * @Description:
 **/
@RestController
@RequestMapping("/shop/type")
public class TbTypeController {
    @Autowired
    TbTypeService tbTypeService;


    /**
     * 添加类型
     * @return
     */
    @PostMapping
    public Result addType(@RequestBody TbType type){
        return tbTypeService.addType(type);
    }

    /**
     * 删除类型
     * @param typeId
     * @return
     */
    @DeleteMapping("/deleteTypeByid/{typeId}")
    public Result deleteTypeByid(@PathVariable("typeId") Integer typeId){
        return tbTypeService.deleteTypeByid(typeId);
    }

    /**
     * 获取树形列表
     * @return
     */
    @GetMapping
    public Result getTreeList(){
        return tbTypeService.getTreeList();
    }

    /**
     * 获取树形下拉框
     * @return
     */
    @GetMapping("/getSelectTree")
    public Result getSelectTree(){
        return tbTypeService.getSelectTree();
    }

    /**
     * 修改类型状态
     * @param typeId
     * @param typeStatus
     * @return
     */
    @PostMapping("/setTypeStatus/{typeId}/{typeStatus}")
    public Result setTypeStatus(@PathVariable("typeId") Integer typeId,@PathVariable("typeStatus") Integer typeStatus){
        return tbTypeService.setTypeStatus(typeId,typeStatus);
    }

    /**
     * 删除类型
     * @param typeId
     * @return
     */
    @PostMapping("/deleteType/{typeId}")
    public Result deleteType(@PathVariable("typeId") Integer typeId){
        return tbTypeService.deleteType(typeId);
    }

    /**
     * 上传图片
     * @param file
     * @return
     */
    @PostMapping("/updataImage")
    public Result updataImage(@RequestPart("file") MultipartFile file){
        return tbTypeService.updataImage(file);
    }

    /**
     * 修改状态
     * @return
     */
    @PostMapping("/updataType")
    public Result updataType(@RequestBody TbType type){
        return tbTypeService.updataType(type);
    }

    /**
     * 添加
     * @return
     */
    @PostMapping("/AddType")
    public Result AddType(@RequestBody TbType type){
        return tbTypeService.AddType(type);
    }
}
